home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP08.ZIP / CHAP08 / SCHMOO / SCHMOO.H < prev    next >
C/C++ Source or Header  |  1993-05-18  |  6KB  |  241 lines

  1. /*
  2.  * SCHMOO.H
  3.  * Chapter 8 Modification
  4.  *
  5.  * Single include file that pulls in everything needed for other source
  6.  * files in the Schmoo application.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _SCHMOO_H_
  19. #define _SCHMOO_H_
  20.  
  21. #include <windows.h>
  22. #include <memory.h>
  23. #include <ole2.h>   //Required for storage use
  24. #include <ole2ver.h>
  25. #include <bookguid.h>
  26.  
  27. //These include files reference DLLs that don't have extern "C" already
  28. extern "C"
  29.     {
  30.     #include <commdlg.h>
  31.     }
  32.  
  33. #include <classlib.h>
  34. #include "resource.h"
  35.  
  36.  
  37. //Get the editor window information.
  38. #include "polyline.h"
  39.  
  40.  
  41.  
  42. //SCHMOO.CPP:  Frame object that creates a main window
  43.  
  44. class __far CSchmooFrame : public CFrame
  45.     {
  46.     private:
  47.         HBITMAP         m_hBmpLines[5];     //Menu item bitmaps
  48.         BOOL            m_fInitialized;     //Did CoInitalize work?
  49.  
  50.     protected:
  51.         //Overridable for creating a CClient for this frame
  52.         virtual LPCClient CreateCClient(void);
  53.  
  54.         virtual BOOL      FRegisterAllClasses(void);
  55.         virtual BOOL      FPreShowInit(void);
  56.         virtual UINT      CreateGizmos(void);
  57.  
  58.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  59.         virtual void      OnDocumentDataChange(LPCDocument);
  60.         virtual void      OnDocumentActivate(LPCDocument);
  61.  
  62.         //New for this class
  63.         virtual void      CreateLineMenu(void);
  64.  
  65.     public:
  66.         CSchmooFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  67.         virtual ~CSchmooFrame(void);
  68.  
  69.         //Overrides
  70.         virtual BOOL      FInit(LPFRAMEINIT);
  71.         virtual void      UpdateMenus(HMENU, UINT);
  72.         virtual void      UpdateGizmos(void);
  73.  
  74.         //New for this class
  75.         virtual void      CheckLineSelection(UINT);
  76.     };
  77.  
  78.  
  79. typedef CSchmooFrame FAR * LPCSchmooFrame;
  80.  
  81.  
  82.  
  83.  
  84.  
  85. //CLIENT.CPP
  86.  
  87. /*
  88.  * The only reason we have a derived class here is to override
  89.  * CreateCDocument so we can create our own type as well as
  90.  * overriding NewDocument to perform one other piece of work once the
  91.  * document's been created.
  92.  */
  93.  
  94. class __far CSchmooClient : public CClient
  95.     {
  96.     protected:
  97.         //Overridable for creating a new CDocument
  98.         virtual LPCDocument CreateCDocument();
  99.  
  100.     public:
  101.         CSchmooClient(HINSTANCE);
  102.         virtual ~CSchmooClient(void);
  103.  
  104.         virtual LPCDocument NewDocument(BOOL, LPCDocumentAdviseSink);
  105.     };
  106.  
  107.  
  108. typedef CSchmooClient FAR * LPCSchmooClient;
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. //DOCUMENT.CPP
  116.  
  117. //Constant ID for the window polyline that lives in a document window
  118. #define ID_POLYLINE         10
  119.  
  120. class __far CSchmooDoc : public CDocument
  121.     {
  122.     friend class CPolylineAdviseSink;
  123.  
  124.     //CHAPTER8MOD
  125.     //These need access to FQueryPasteFromData, FPasteFromData
  126.     friend class CDropTarget;
  127.     friend class CDropSource;
  128.     //End CHAPTER8MOD
  129.  
  130.     protected:
  131.         UINT            m_uPrevSize;        //Last WM_SIZE wParam
  132.         LONG            m_lVer;             //Loaded Polyline version
  133.  
  134.         LPCPolyline             m_pPL;      //Polyline Editor window in us.
  135.         LPCPolylineAdviseSink   m_pPLAdv;   //Advises from Polyline
  136.  
  137.         //CHAPTER8MOD
  138.         class CDropTarget FAR *m_pDropTarget;  //Registered target.
  139.  
  140.         BOOL            m_fDragSource;      //Drag-drop source==target
  141.         //End CHAPTER8MOD
  142.  
  143.     protected:
  144.         virtual BOOL    FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
  145.  
  146.         virtual BOOL    FQueryPasteFromData(LPDATAOBJECT);
  147.         virtual BOOL    FPasteFromData(LPDATAOBJECT);
  148.         LPDATAOBJECT    TransferObjectCreate(void);
  149.  
  150.         //CHAPTER8MOD
  151.         void            DropSelectTargetWindow(void);
  152.         //End CHAPTER8MOD
  153.  
  154.     public:
  155.         CSchmooDoc(HINSTANCE);
  156.         virtual ~CSchmooDoc(void);
  157.  
  158.         virtual BOOL     FInit(LPDOCUMENTINIT);
  159.         virtual void     Clear();
  160.  
  161.         virtual UINT     ULoad(BOOL, LPSTR);
  162.         virtual UINT     USave(UINT, LPSTR);
  163.  
  164.         virtual void     Undo(void);
  165.         virtual BOOL     FClip(HWND, BOOL);
  166.         virtual HGLOBAL  RenderFormat(UINT);
  167.         virtual BOOL     FQueryPaste(void);
  168.         virtual BOOL     FPaste(HWND);
  169.  
  170.         virtual COLORREF ColorSet(UINT, COLORREF);
  171.         virtual COLORREF ColorGet(UINT);
  172.  
  173.         virtual UINT     LineStyleSet(UINT);
  174.         virtual UINT     LineStyleGet();
  175.     };
  176.  
  177. typedef CSchmooDoc FAR * LPCSchmooDoc;
  178.  
  179.  
  180. //These color indices wrap the polyline definitions
  181. #define DOCCOLOR_BACKGROUND             POLYLINECOLOR_BACKGROUND
  182. #define DOCCOLOR_LINE                   POLYLINECOLOR_LINE
  183.  
  184.  
  185.  
  186. //CHAPTER8MOD
  187. //Drag-drop interfaces we need in the document
  188. class __far CDropTarget : public IDropTarget
  189.     {
  190.     protected:
  191.         ULONG               m_cRef;      //Interface reference count.
  192.         LPCSchmooDoc        m_pDoc;      //Back pointer to the document
  193.  
  194.         LPDATAOBJECT        m_pIDataObject;  //Data object from DragEnter
  195.  
  196.     public:
  197.         CDropTarget(LPCSchmooDoc);
  198.         ~CDropTarget(void);
  199.  
  200.         //IDropTarget interface members
  201.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  202.         STDMETHODIMP_(ULONG) AddRef(void);
  203.         STDMETHODIMP_(ULONG) Release(void);
  204.  
  205.         STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  206.         STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
  207.         STDMETHODIMP DragLeave(void);
  208.         STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
  209.     };
  210.  
  211.  
  212. typedef CDropTarget FAR * LPCDropTarget;
  213.  
  214.  
  215. class __far CDropSource : public IDropSource
  216.     {
  217.     protected:
  218.         ULONG               m_cRef;      //Interface reference count.
  219.         LPCSchmooDoc        m_pDoc;      //Back pointer to the document
  220.  
  221.     public:
  222.         CDropSource(LPCSchmooDoc);
  223.         ~CDropSource(void);
  224.  
  225.         //IDropSource interface members
  226.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  227.         STDMETHODIMP_(ULONG) AddRef(void);
  228.         STDMETHODIMP_(ULONG) Release(void);
  229.  
  230.         STDMETHODIMP QueryContinueDrag(BOOL, DWORD);
  231.         STDMETHODIMP GiveFeedback(DWORD);
  232.     };
  233.  
  234.  
  235. typedef CDropSource FAR * LPCDropSource;
  236.  
  237. //End CHAPTER8MOD
  238.  
  239.  
  240. #endif //_SCHMOO_H_
  241.